import csv

def file_write(list_student: list) -> None:
    with open('out_file.csv', 'w', newline='') as csvfile:
        for student in list_student:
            data = ";".join(student) +"\n"
            csvfile.write(data)

def read_file() -> list:
    with open('salary.csv', "r", encoding="utf-8") as csvfile:
        reader = [*csv.DictReader(csvfile, delimiter=";")]
    return reader

def proc_4(a: int, b: int):
    return ((b-a)/b) *100

def salary(dist, start, end):
    list_reg = read_file()
    list_rez = [['Субъект', str(start), str(end)]]
    for dict_reg in list_reg:
        if dict_reg["Федеральный округ"] == dist:
            if proc_4(int(dict_reg[str(start)]),int(dict_reg[str(end)])) < 4:
                list_rez.append([dict_reg["Субъект"],dict_reg[str(start)], dict_reg[str(end)]])

    file_write(list_rez)
salary('Северо - Западный', 2018, 2019)
with open('out_file.csv', "r", encoding="utf-8") as csvfile:
    reader = [*csv.reader(csvfile, delimiter=";")]
    assert reader == [['Субъект', '2018', '2019'],
                      ['Республика Коми', '44853', '46609'],
                      ['Калининградская область', '29726', '30883'],
                      ['Ленинградская область', '38372', '39280'],
                      ['Новгородская область', '28037', '28232']]